<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="门店名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入门店名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="真实姓名" prop="realName">
        <el-input
          v-model="queryParams.realName"
          placeholder="请输入真实姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="联系人" prop="linkName">
        <el-input
          v-model="queryParams.linkName"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系电话" prop="linkPhone">
        <el-input
          v-model="queryParams.linkPhone"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入联系地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="总货款" prop="totalMoney">
        <el-input
          v-model="queryParams.totalMoney"
          placeholder="请输入总货款"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="当前可提现金额" prop="money">
        <el-input
          v-model="queryParams.money"
          placeholder="请输入当前可提现金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="已冻结金额" prop="freezeMoney">
        <el-input
          v-model="queryParams.freezeMoney"
          placeholder="请输入已冻结金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="累积提现佣金" prop="cashMoney">
        <el-input
          v-model="queryParams.cashMoney"
          placeholder="请输入累积提现佣金"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="保证金" prop="depositMoney">
        <el-input
          v-model="queryParams.depositMoney"
          placeholder="请输入保证金"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="会员id" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入会员id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="关注人数" prop="favCount">
        <el-input
          v-model="queryParams.favCount"
          placeholder="请输入关注人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="收到的礼物币总数" prop="totalGift">
        <el-input
          v-model="queryParams.totalGift"
          placeholder="请输入收到的礼物币总数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="是否总店，0否1是" prop="isMain">
        <el-input
          v-model="queryParams.isMain"
          placeholder="请输入是否总店，0否1是"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="门店坐标经度" prop="longitude">
        <el-input
          v-model="queryParams.longitude"
          placeholder="请输入门店坐标经度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="门店坐标纬度" prop="latitude">
        <el-input
          v-model="queryParams.latitude"
          placeholder="请输入门店坐标纬度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="配送费" prop="shippingFee">
        <el-input
          v-model="queryParams.shippingFee"
          placeholder="请输入配送费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="包装费" prop="bagPrice">
        <el-input
          v-model="queryParams.bagPrice"
          placeholder="请输入包装费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="店内包装费" prop="storebagPrice">
        <el-input
          v-model="queryParams.storebagPrice"
          placeholder="请输入店内包装费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="外卖营业时间" prop="deliveryTime">
        <el-input
          v-model="queryParams.deliveryTime"
          placeholder="请输入外卖营业时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="自提营业时间" prop="pickTime">
        <el-input
          v-model="queryParams.pickTime"
          placeholder="请输入自提营业时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="店内营业时间" prop="storeTime">
        <el-input
          v-model="queryParams.storeTime"
          placeholder="请输入店内营业时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="配送范围km" prop="deliveryDistance">
        <el-input
          v-model="queryParams.deliveryDistance"
          placeholder="请输入配送范围km"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="外卖配送方式" prop="deliverySet">
        <el-input
          v-model="queryParams.deliverySet"
          placeholder="请输入外卖配送方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="店内用餐方式" prop="storeSet">
        <el-input
          v-model="queryParams.storeSet"
          placeholder="请输入店内用餐方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="最低消费" prop="minMoney">
        <el-input
          v-model="queryParams.minMoney"
          placeholder="请输入最低消费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="服务费" prop="serviceMoney">
        <el-input
          v-model="queryParams.serviceMoney"
          placeholder="请输入服务费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="0定时清台1立即清台" prop="autoClose">
        <el-input
          v-model="queryParams.autoClose"
          placeholder="请输入0定时清台1立即清台"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="0分钟清台" prop="closeTime">
        <el-input
          v-model="queryParams.closeTime"
          placeholder="请输入0分钟清台"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="商品分类" prop="categorySet">
        <el-input
          v-model="queryParams.categorySet"
          placeholder="请输入商品分类设置10同步主店20分店创建"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="是否删除0，否1是" prop="isDelete">
        <el-input
          v-model="queryParams.isDelete"
          placeholder="请输入是否删除0，否1是"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['eaten:supplier:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['eaten:supplier:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['eaten:supplier:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['eaten:supplier:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="supplierList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="主键id" align="center" prop="shopSupplierId" /> -->
      <el-table-column label="门店名称" align="center" prop="name" />
      <!-- <el-table-column label="真实姓名" align="center" prop="realName" /> -->
      <el-table-column label="联系人" align="center" prop="linkName" />
      <el-table-column label="联系电话" align="center" prop="linkPhone" />
      <el-table-column label="logo" align="center" prop="logo" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.logo" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column
        label="联系地址"
        align="center"
        :show-overflow-tooltip="true"
        prop="address"
      />
      <!-- <el-table-column label="营业执照" align="center" prop="businessId" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.businessId" :width="50" :height="50"/>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="营业执照" align="center" prop="businessId" /> -->
      <el-table-column
        label="商家介绍"
        align="center"
        :show-overflow-tooltip="true"
        prop="description"
      />
      <!-- <el-table-column label="总货款" align="center" prop="totalMoney" /> -->
      <!-- <el-table-column label="当前可提现金额" align="center" prop="money" />
      <el-table-column label="已冻结金额" align="center" prop="freezeMoney" />
      <el-table-column label="累积提现佣金" align="center" prop="cashMoney" /> -->
      <!-- <el-table-column label="保证金" align="center" prop="depositMoney" /> -->
      <!-- <el-table-column label="会员id" align="center" prop="userId" /> -->
      <!-- <el-table-column label="关注人数" align="center" prop="favCount" /> -->
      <!-- 店铺状态0营业中1停止营业 -->
      <el-table-column label="店铺状态" align="center" prop="status" >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.supplier_yy"
            :value="scope.row.status"
          />
        </template>
      </el-table-column>
      <!-- 店铺类型10加盟20自营 -->
      <!-- <el-table-column label="店铺类型" align="center" prop="storeType" /> -->
      <!-- <el-table-column label="收到的礼物币总数" align="center" prop="totalGift" /> -->
      <!-- 是否禁用0否1是 -->
      <!-- <el-table-column label="是否禁用" align="center" prop="isRecycle" /> -->
      <!-- 是否总店，0否1是 -->
      <!-- <el-table-column label="是否总店" align="center" prop="isMain" /> -->
      <!-- <el-table-column label="所在省份id" align="center" prop="provinceId" />
      <el-table-column label="所在城市id" align="center" prop="cityId" />
      <el-table-column label="所在辖区id" align="center" prop="regionId" />
      <el-table-column label="门店坐标经度" align="center" prop="longitude" />
      <el-table-column label="门店坐标纬度" align="center" prop="latitude" />
      <el-table-column label="配送费" align="center" prop="shippingFee" />
      <el-table-column label="包装费类型0按商品收费1按单收费" align="center" prop="bagType" />
      <el-table-column label="包装费" align="center" prop="bagPrice" />
      <el-table-column label="店内包装费类型0按商品收费1按单收费" align="center" prop="storebagType" />
      <el-table-column label="店内包装费" align="center" prop="storebagPrice" /> -->
      <!-- <el-table-column label="外卖营业时间" align="center" prop="deliveryTime" />
      <el-table-column label="自提营业时间" align="center" prop="pickTime" />
      <el-table-column label="店内营业时间" align="center" prop="storeTime" /> -->
      <!-- <el-table-column label="配送范围km" align="center" prop="deliveryDistance" /> -->
      <!-- <el-table-column label="外卖配送方式" align="center" prop="deliverySet" />
      <el-table-column label="店内用餐方式" align="center" prop="storeSet" />
      <el-table-column label="最低消费" align="center" prop="minMoney" /> -->
      <!-- 计算模式10先结账后用餐20先用餐后结账 -->
      <!-- <el-table-column label="计算模式" align="center" prop="settleType" /> -->
      <!-- 服务费类型0按就餐人数1按桌台收费 -->
      <!-- <el-table-column label="服务费类型" align="center" prop="serviceType" /> -->
      <!-- <el-table-column label="服务费" align="center" prop="serviceMoney" />
      <el-table-column label="0定时清台1立即清台" align="center" prop="autoClose" />
      <el-table-column label="0分钟清台" align="center" prop="closeTime" />
      <el-table-column label="商品分类设置10同步主店20分店创建" align="center" prop="categorySet" /> -->
      <!-- 是否删除0，否1是 -->
      <el-table-column label="是否删除" align="center" prop="isDelete" >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.supplier_delete"
            :value="scope.row.isDelete"
          />
        </template>
      </el-table-column>
      <!-- <el-table-column label="程序id" align="center" prop="appId" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['eaten:supplier:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['eaten:supplier:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改供应商对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="门店名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入门店名称" />
        </el-form-item>
        <!-- <el-form-item label="真实姓名" prop="realName">
          <el-input v-model="form.realName" placeholder="请输入真实姓名" />
        </el-form-item> -->
        <el-form-item label="联系人" prop="linkName">
          <el-input v-model="form.linkName" placeholder="请输入联系人" />
        </el-form-item>
        <el-form-item label="联系电话" prop="linkPhone">
          <el-input v-model="form.linkPhone" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="logo" prop="logo">
          <image-upload v-model="form.logo" />
        </el-form-item>
        <el-form-item label="联系地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入联系地址" />
        </el-form-item>
        <el-form-item label="营业执照" prop="businessId">
          <el-input v-model="form.businessId" placeholder="请输入营业执照" />
        </el-form-item>
        <el-form-item label="商家介绍" prop="description">
          <el-input
            v-model="form.description"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <!-- <el-form-item label="总货款" prop="totalMoney">
          <el-input v-model="form.totalMoney" placeholder="请输入总货款" />
        </el-form-item>
        <el-form-item label="当前可提现金额" prop="money">
          <el-input v-model="form.money" placeholder="请输入当前可提现金额" />
        </el-form-item>
        <el-form-item label="已冻结金额" prop="freezeMoney">
          <el-input v-model="form.freezeMoney" placeholder="请输入已冻结金额" />
        </el-form-item>
        <el-form-item label="累积提现佣金" prop="cashMoney">
          <el-input v-model="form.cashMoney" placeholder="请输入累积提现佣金" />
        </el-form-item>
        <el-form-item label="保证金" prop="depositMoney">
          <el-input v-model="form.depositMoney" placeholder="请输入保证金" />
        </el-form-item>
        <el-form-item label="会员id" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入会员id" />
        </el-form-item>
        <el-form-item label="关注人数" prop="favCount">
          <el-input v-model="form.favCount" placeholder="请输入关注人数" />
        </el-form-item>
        <el-form-item label="收到的礼物币总数" prop="totalGift">
          <el-input
            v-model="form.totalGift"
            placeholder="请输入收到的礼物币总数"
          />
        </el-form-item>
        <el-form-item label="是否总店，0否1是" prop="isMain">
          <el-input
            v-model="form.isMain"
            placeholder="请输入是否总店，0否1是"
          />
        </el-form-item>
        <el-form-item label="门店坐标经度" prop="longitude">
          <el-input v-model="form.longitude" placeholder="请输入门店坐标经度" />
        </el-form-item>
        <el-form-item label="门店坐标纬度" prop="latitude">
          <el-input v-model="form.latitude" placeholder="请输入门店坐标纬度" />
        </el-form-item>
        <el-form-item label="配送费" prop="shippingFee">
          <el-input v-model="form.shippingFee" placeholder="请输入配送费" />
        </el-form-item>
        <el-form-item label="包装费" prop="bagPrice">
          <el-input v-model="form.bagPrice" placeholder="请输入包装费" />
        </el-form-item>
        <el-form-item label="店内包装费" prop="storebagPrice">
          <el-input
            v-model="form.storebagPrice"
            placeholder="请输入店内包装费"
          />
        </el-form-item>
        <el-form-item label="外卖营业时间" prop="deliveryTime">
          <el-input
            v-model="form.deliveryTime"
            placeholder="请输入外卖营业时间"
          />
        </el-form-item>
        <el-form-item label="自提营业时间" prop="pickTime">
          <el-input v-model="form.pickTime" placeholder="请输入自提营业时间" />
        </el-form-item>
        <el-form-item label="店内营业时间" prop="storeTime">
          <el-input v-model="form.storeTime" placeholder="请输入店内营业时间" />
        </el-form-item>
        <el-form-item label="配送范围km" prop="deliveryDistance">
          <el-input
            v-model="form.deliveryDistance"
            placeholder="请输入配送范围km"
          />
        </el-form-item>
        <el-form-item label="外卖配送方式" prop="deliverySet">
          <el-input
            v-model="form.deliverySet"
            placeholder="请输入外卖配送方式"
          />
        </el-form-item>
        <el-form-item label="店内用餐方式" prop="storeSet">
          <el-input v-model="form.storeSet" placeholder="请输入店内用餐方式" />
        </el-form-item>
        <el-form-item label="最低消费" prop="minMoney">
          <el-input v-model="form.minMoney" placeholder="请输入最低消费" />
        </el-form-item>
        <el-form-item label="服务费" prop="serviceMoney">
          <el-input v-model="form.serviceMoney" placeholder="请输入服务费" />
        </el-form-item>
        <el-form-item label="0定时清台1立即清台" prop="autoClose">
          <el-input
            v-model="form.autoClose"
            placeholder="请输入0定时清台1立即清台"
          />
        </el-form-item>
        <el-form-item label="0分钟清台" prop="closeTime">
          <el-input v-model="form.closeTime" placeholder="请输入0分钟清台" />
        </el-form-item>
        <el-form-item
          label="商品分类设置10同步主店20分店创建"
          prop="categorySet"
        >
          <el-input
            v-model="form.categorySet"
            placeholder="请输入商品分类设置10同步主店20分店创建"
          />
        </el-form-item>
        <el-form-item label="是否删除0，否1是" prop="isDelete">
          <el-input
            v-model="form.isDelete"
            placeholder="请输入是否删除0，否1是"
          />
        </el-form-item> -->
        <el-form-item label="是否删除" prop="isDelete">
          <el-radio-group v-model="form.isDelete" @change="handleTypeChange">
            <el-radio :label="0">未删除</el-radio>
            <el-radio :label="1">已删除</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="店铺状态" prop="status">
          <el-radio-group v-model="form.status" @change="handleTypeChange">
            <el-radio :label="0">营业中</el-radio>
            <el-radio :label="1">停止营业</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listSupplier,
  getSupplier,
  delSupplier,
  addSupplier,
  updateSupplier,
} from "@/api/eaten/supplier";

export default {
  dicts: ["supplier_yy","supplier_delete"],
  name: "Supplier",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 供应商表格数据
      supplierList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        realName: null,
        linkName: null,
        linkPhone: null,
        logo: null,
        address: null,
        businessId: null,
        description: null,
        totalMoney: null,
        money: null,
        freezeMoney: null,
        cashMoney: null,
        depositMoney: null,
        userId: null,
        favCount: null,
        status: null,
        storeType: null,
        totalGift: null,
        isRecycle: null,
        isMain: null,
        provinceId: null,
        cityId: null,
        regionId: null,
        longitude: null,
        latitude: null,
        shippingFee: null,
        bagType: null,
        bagPrice: null,
        storebagType: null,
        storebagPrice: null,
        deliveryTime: null,
        pickTime: null,
        storeTime: null,
        deliveryDistance: null,
        deliverySet: null,
        storeSet: null,
        minMoney: null,
        settleType: null,
        serviceType: null,
        serviceMoney: null,
        autoClose: null,
        closeTime: null,
        categorySet: null,
        isDelete: null,
        appId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          { required: true, message: "供应商姓名不能为空", trigger: "blur" },
        ],
        linkName: [
          { required: true, message: "联系人不能为空", trigger: "blur" },
        ],
        logo: [{ required: true, message: "logo不能为空", trigger: "blur" }],
        address: [
          { required: true, message: "联系地址不能为空", trigger: "blur" },
        ],
        businessId: [
          { required: true, message: "营业执照不能为空", trigger: "blur" },
        ],
        description: [
          { required: true, message: "商家介绍不能为空", trigger: "blur" },
        ],
        userId: [
          { required: true, message: "会员id不能为空", trigger: "blur" },
        ],
        status: [
          {
            required: true,
            message: "店铺状态0营业中1停止营业不能为空",
            trigger: "change",
          },
        ],
        storeType: [
          {
            required: true,
            message: "店铺类型10加盟20自营不能为空",
            trigger: "change",
          },
        ],
        isRecycle: [
          {
            required: true,
            message: "是否禁用0否1是不能为空",
            trigger: "blur",
          },
        ],
        provinceId: [
          { required: true, message: "所在省份id不能为空", trigger: "blur" },
        ],
        cityId: [
          { required: true, message: "所在城市id不能为空", trigger: "blur" },
        ],
        regionId: [
          { required: true, message: "所在辖区id不能为空", trigger: "blur" },
        ],
        longitude: [
          { required: true, message: "门店坐标经度不能为空", trigger: "blur" },
        ],
        latitude: [
          { required: true, message: "门店坐标纬度不能为空", trigger: "blur" },
        ],
        shippingFee: [
          { required: true, message: "配送费不能为空", trigger: "blur" },
        ],
        bagType: [
          {
            required: true,
            message: "包装费类型0按商品收费1按单收费不能为空",
            trigger: "change",
          },
        ],
        bagPrice: [
          { required: true, message: "包装费不能为空", trigger: "blur" },
        ],
        storebagType: [
          {
            required: true,
            message: "店内包装费类型0按商品收费1按单收费不能为空",
            trigger: "change",
          },
        ],
        storebagPrice: [
          { required: true, message: "店内包装费不能为空", trigger: "blur" },
        ],
        deliveryTime: [
          { required: true, message: "外卖营业时间不能为空", trigger: "blur" },
        ],
        pickTime: [
          { required: true, message: "自提营业时间不能为空", trigger: "blur" },
        ],
        storeTime: [
          { required: true, message: "店内营业时间不能为空", trigger: "blur" },
        ],
        deliveryDistance: [
          { required: true, message: "配送范围km不能为空", trigger: "blur" },
        ],
        deliverySet: [
          { required: true, message: "外卖配送方式不能为空", trigger: "blur" },
        ],
        storeSet: [
          { required: true, message: "店内用餐方式不能为空", trigger: "blur" },
        ],
        minMoney: [
          { required: true, message: "最低消费不能为空", trigger: "blur" },
        ],
        settleType: [
          {
            required: true,
            message: "计算模式10先结账后用餐20先用餐后结账不能为空",
            trigger: "change",
          },
        ],
        serviceType: [
          {
            required: true,
            message: "服务费类型0按就餐人数1按桌台收费不能为空",
            trigger: "change",
          },
        ],
        serviceMoney: [
          { required: true, message: "服务费不能为空", trigger: "blur" },
        ],
        autoClose: [
          {
            required: true,
            message: "0定时清台1立即清台不能为空",
            trigger: "blur",
          },
        ],
        closeTime: [
          { required: true, message: "0分钟清台不能为空", trigger: "blur" },
        ],
        categorySet: [
          {
            required: true,
            message: "商品分类设置10同步主店20分店创建不能为空",
            trigger: "blur",
          },
        ],
        appId: [{ required: true, message: "程序id不能为空", trigger: "blur" }],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询供应商列表 */
    getList() {
      this.loading = true;
      listSupplier(this.queryParams).then((response) => {
        this.supplierList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        shopSupplierId: null,
        name: null,
        realName: null,
        linkName: null,
        linkPhone: null,
        logo: null,
        address: null,
        businessId: null,
        description: null,
        totalMoney: null,
        money: null,
        freezeMoney: null,
        cashMoney: null,
        depositMoney: null,
        userId: null,
        favCount: null,
        status: null,
        storeType: null,
        totalGift: null,
        isRecycle: null,
        isMain: null,
        provinceId: null,
        cityId: null,
        regionId: null,
        longitude: null,
        latitude: null,
        shippingFee: null,
        bagType: null,
        bagPrice: null,
        storebagType: null,
        storebagPrice: null,
        deliveryTime: null,
        pickTime: null,
        storeTime: null,
        deliveryDistance: null,
        deliverySet: null,
        storeSet: null,
        minMoney: null,
        settleType: null,
        serviceType: null,
        serviceMoney: null,
        autoClose: null,
        closeTime: null,
        categorySet: null,
        isDelete: null,
        appId: null,
        createTime: null,
        updateTime: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.shopSupplierId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加供应商";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const shopSupplierId = row.shopSupplierId || this.ids;
      getSupplier(shopSupplierId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改供应商";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.shopSupplierId != null) {
            updateSupplier(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSupplier(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const shopSupplierIds = row.shopSupplierId || this.ids;
      this.$modal
        .confirm('是否确认删除供应商编号为"' + shopSupplierIds + '"的数据项？')
        .then(function () {
          return delSupplier(shopSupplierIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "eaten/supplier/export",
        {
          ...this.queryParams,
        },
        `supplier_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
